home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 2003 June / macformat-130.iso / mac / Reviewed⁄Demos / Spearhead Demo / demota / pak1.pk3 / global / weather.scr < prev    next >
Encoding:
Text File  |  2002-10-21  |  9.9 KB  |  518 lines

  1. main:
  2. // local.weatherroof local.weatherwindow local.weatherin local.weatherout local.weatherflash local.weathertreewind 
  3.  
  4. //    if (getcvar(superfps) == "1")
  5. //        end
  6.  
  7. level.rain_width = "0.4"
  8. level.rain_min_dist = 512
  9. // setcvar "cg_density" "10"
  10.     level.startedrainsound1 = 1
  11.     level.startedrainsound2 = 1
  12.  
  13.     level.farplane = $world.farplane
  14.     level.farplane_color = $world.farplane_color
  15.  
  16.     $world farplane level.farplane
  17.     $world farplane_color level.farplane_color
  18.  
  19.  
  20.  
  21.     if ($weatherF == NULL)
  22.         level.weatherFs = 0
  23.         else
  24.         level.weatherFs = $weatherF.size
  25.  
  26.     if (level.weatherFs > 0)
  27.         level.weatherF = exec global/makearray.scr $weatherF
  28.  
  29.     if ($weatherR == NULL)
  30.         level.weatherRs = 0
  31.         else
  32.         level.weatherRs = $weatherR.size
  33.  
  34.     if (level.weatherRs > 0)
  35.     {
  36.         level.weatherR = exec global/makearray.scr $weatherR
  37.         level.weatherR model "fx/dummy.tik"
  38.     }
  39.  
  40.     if ($weatherI == NULL)
  41.         level.weatherIs = 0
  42.         else
  43.         level.weatherIs = $weatherI.size
  44.  
  45.     if (level.weatherIs > 0)
  46.         level.weatherI = exec global/makearray.scr $weatherI
  47.  
  48.     if ($weatherW == NULL)
  49.         level.weatherWs = 0
  50.         else
  51.         level.weatherWs = $weatherW.size
  52.  
  53.     if (level.weatherWs > 0)
  54.     {
  55.         level.weatherW = exec global/makearray.scr $weatherW
  56.         level.weatherW model "fx/dummy.tik"
  57.     }
  58.  
  59.     if ($wind == NULL)
  60.         level.winds = 0
  61.         else
  62.         level.winds = $wind.size
  63.  
  64.     if (level.winds > 0)
  65.         level.wind = exec global/makearray.scr $wind
  66.  
  67.  
  68.     level waittill spawn
  69. //end
  70.  
  71.     level.gametype = int( getcvar( g_gametype ) )
  72.  
  73. level.rain = 0.0
  74.  
  75. if( level.gametype == 0 )
  76. {
  77.     spawn script_model "targetname" "playersound"
  78.     $playersound thread playersoundorg
  79.     $playersound model "fx/dummy.tik"
  80.     $playersound notsolid
  81.  
  82.     spawn script_model "targetname" "playersound2"
  83.     $playersound2 thread playersoundorg
  84.     $playersound2 model "fx/dummy.tik"
  85.     $playersound2 notsolid
  86.  
  87.     spawn script_model "targetname" "playersound3"
  88.     $playersound3 thread playersoundorg
  89.     $playersound3 model "fx/dummy.tik"
  90.     $playersound3 notsolid
  91. }
  92.  
  93. thread unflash
  94. wait 1
  95.  setcvar "r_fastsky" "0.5"
  96. $world farplane level.farplane
  97.  
  98.     if (level.windtime == NIL)
  99.         level.windtime = 15
  100.  
  101.     if (level.shuttertime == NIL)
  102.         level.shuttertime = 0.8
  103.  
  104.     if (level.rainvolume == NIL)
  105.         level.rainvolume = -1
  106.  
  107.     if (level.raindensity == NIL)
  108.         level.raindensity = -1
  109.  
  110.     if (level.thundertime == NIL)
  111.         level.thundertime = 20
  112.  
  113. thread thunder
  114. if (game.medic != NIL)
  115.     thread medicchanger
  116. else
  117.     thread weatherchanger
  118.  
  119. thread treemovement
  120.  
  121. for (local.i=1;local.i<level.interiors+1;local.i++)
  122.     level.interior[local.i] thread rainin
  123.  
  124. for (local.i=1;local.i<level.exteriors+1;local.i++)
  125.     level.exterior[local.i] thread rainout
  126.  
  127.  
  128.  
  129. level.raindest = 0.0
  130.  
  131. thread weatherpattern
  132.     local.raintime = level.time
  133.     rainvar:
  134.         
  135.         if (level.rain < level.raindest)
  136.         {
  137.             thread weatherloop
  138.             level.rain = level.rain + 0.1
  139.         }
  140.         else
  141.         if (level.rain > level.raindest)
  142.         {
  143.             thread weatherloop
  144.             level.rain = level.rain - 0.1
  145.         }
  146.         else
  147.         if (level.time > local.raintime)
  148.         {
  149.             thread weatherloop
  150.             local.raintime = level.time + 2
  151.         }
  152.  
  153.     
  154.         wait 0.1
  155.  
  156.     goto rainvar
  157.  
  158.  
  159. end
  160.  
  161.  
  162.  
  163.  
  164.  
  165. weatherpattern:
  166. if (level.weatherpattern == 0)
  167. {
  168. local.windtime = 15
  169. local.shuttertime = 0.8
  170. local.rainvolume = -1
  171. local.raindensity = -1
  172. local.thundertime = 20
  173. }
  174. else
  175. if (level.weatherpattern == 1)
  176. {
  177. local.windtime = 5
  178. local.shuttertime = 0.3
  179. local.rainvolume = 0.2
  180. local.raindensity = 0.8
  181. local.thundertime = 8
  182. }
  183. else
  184. if (level.weatherpattern == 2)
  185. {
  186. local.windtime = 3
  187. local.shuttertime = 0.2
  188. local.rainvolume = 0.4
  189. local.raindensity = 3
  190. local.thundertime = 6
  191. }
  192. else
  193. if (level.weatherpattern == 3)
  194. {
  195. local.windtime = 1.5
  196. local.shuttertime = 0.1
  197. local.rainvolume = 1
  198. local.raindensity = 10
  199. local.thundertime = 4
  200. }
  201.  
  202.  
  203. // local.trans = 0.15
  204. local.trans = 0.07
  205. level.windtime = (local.windtime * local.trans + (level.windtime * (1 - local.trans)))
  206. level.shuttertime = (local.shuttertime * local.trans + (level.shuttertime * (1 - local.trans)))
  207. level.raindensity = (local.raindensity * local.trans + (level.raindensity * (1 - local.trans)))
  208. level.rainvolume = (local.rainvolume * local.trans + (level.rainvolume * (1 - local.trans)))
  209. level.thundertime = (local.thundertime * local.trans + (level.thundertime * (1 - local.trans)))
  210. //println ("Current wind:" + level.windtime + " current shutter:" + level.shuttertime + " current raindensity:" + level.raindensity + " current rainvolume:" + level.rainvolume + " current thundertime:" + level.thundertime)
  211.  
  212. if ((level.raindensity > 0.4) && (level.rainvolume < 0.1))
  213. level.rainvolume = 0.1
  214.  
  215. wait 1
  216. goto weatherpattern
  217. end
  218.  
  219. weatherchanger:
  220.  
  221. level.weatherpattern = 0
  222. wait 4
  223. w:
  224. level.weatherpattern = 1
  225. wait 10
  226. level.weatherpattern = 2
  227. wait 15
  228. level.weatherpattern = 3
  229.  
  230. wait 60
  231. level.weatherpattern = 2
  232. wait 15
  233. level.weatherpattern = 1
  234. wait 60
  235. // level.weatherpattern = 0
  236. // wait 60
  237. goto w
  238.  
  239. end
  240.  
  241. // 77
  242. medicchanger:
  243.  
  244. level.weatherpattern = 0
  245. wait 5
  246. w2:
  247. level.weatherpattern = 1
  248. wait 10
  249. level.weatherpattern = 2
  250. wait 15
  251. level.weatherpattern = 3
  252.  
  253. wait 20
  254. level.weatherpattern = 2
  255. wait 5
  256. level.weatherpattern = 0
  257. wait 15
  258. // level.weatherpattern = 0
  259. // wait 60
  260. goto w2
  261.  
  262. end
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269. thunder:
  270. wait (level.thundertime + randomint( (level.thundertime * 1.5) ))
  271. local.num = (randomint (3) + 1)
  272. if (local.num == 1)
  273. {
  274. thread flash
  275. wait 0.2
  276. thread unflash
  277. wait 1
  278. thread flash
  279. wait 0.1
  280. thread unflash
  281. wait 0.1
  282. thread flash
  283. wait 0.1
  284. thread unflash
  285. wait (1 + (randomfloat(2)))
  286. }
  287. else
  288. if (local.num == 2)
  289. {
  290. thread flash
  291. wait 0.1
  292. thread unflash
  293. wait 0.1
  294. thread flash
  295. wait 0.1
  296. thread unflash
  297. wait 1
  298. thread flash
  299. wait 0.2
  300. thread unflash
  301. wait (1 + (randomfloat(2)))
  302. }
  303. else
  304. if (local.num == 3)
  305. {
  306. thread flash
  307. wait 0.1
  308. thread unflash
  309. wait 0.1
  310. thread flash
  311. wait 0.2
  312. thread unflash
  313. wait 0.5
  314. thread flash
  315. wait 0.1
  316. thread unflash
  317. wait (1 + (randomfloat(2)))
  318. }
  319.  
  320. if (game.medic == NIL)
  321.     $player playsound thunder
  322. goto thunder
  323.  
  324. end
  325.  
  326. flash:
  327.  setcvar "r_fastsky" "1"
  328. $world farplane_color (0.9 0.9 0.9)
  329.  
  330. for (local.i=1;local.i<level.weatherFs+1;local.i++)
  331. level.weatherF[local.i] show
  332.  
  333. end
  334.  
  335. unflash:
  336.  setcvar "r_fastsky" "0"
  337. $world farplane_color level.farplane_color
  338.  
  339. for (local.i=1;local.i<level.weatherFs+1;local.i++)
  340. level.weatherF[local.i] hide
  341.  
  342. end
  343.  
  344.  
  345. weatherloop:
  346. weatherlooper:
  347. if (level.raindensity < 0)
  348. level.rain_density = 0
  349. else
  350. if (level.raindensity < 1)
  351. level.rain_density = level.raindensity * 10
  352. else
  353. if (level.raindensity < 10)
  354. level.rain_density = level.raindensity
  355. else
  356. level.rain_density = 0.003
  357.  
  358. level.rain_density = level.raindensity // WTF Mackey? 
  359.  
  360. if (level.raindensity < 5)
  361. local.raindensity = 50
  362. else
  363. local.raindensity = (50 + ((level.raindensity - 5) * 8))
  364.  
  365. level.rain_slant = local.raindensity
  366.  
  367. local.rainvolume = level.rainvolume - 0.3
  368. local.rainvolume = local.rainvolume - level.rain
  369.  
  370. /*
  371.     if (level.startedrainsound1 == 0)
  372.     {
  373.         level.startedrainsound1 = 1
  374.         $playersound thread replaysound
  375.     }
  376.  
  377. */
  378. if ( level.gametype == 0 )
  379. {
  380.     if (local.rainvolume > 0)
  381.         $playersound loopsound rain_ext (local.rainvolume + 0.2) "levelwide"
  382.     else
  383.         $playersound loopsound rain_ext 0
  384. }
  385.     
  386. /*
  387.     if (level.startedrainsound2 == 0)
  388.     {
  389.         level.startedrainsound2 = 1
  390.         $playersound2 thread replaysound2
  391.     }
  392.  
  393. */
  394.  
  395.     if (level.rainvolume > 0.4)
  396.         local.rainvolume = (0.4 - (level.rainvolume - 0.4))
  397.     else
  398.         local.rainvolume = level.rainvolume
  399.     
  400.     local.rainvolume = local.rainvolume - level.rain
  401.  
  402. if ( level.gametype == 0 )
  403. {
  404.     if (local.rainvolume < 0.0)
  405.         $playersound2 loopsound rain_puddle 0
  406.     else
  407.         $playersound2 loopsound rain_puddle (local.rainvolume + 0.2) "levelwide"
  408. }
  409.  
  410.  
  411.     local.rainvolume = level.rainvolume - (1.0 - level.rain)
  412.  
  413. if ( level.gametype == 0 )
  414. {
  415.     if (local.rainvolume < 0.0)
  416.         $playersound3 loopsound rain_int 0 
  417.     else
  418.         $playersound3 loopsound rain_int (local.rainvolume + 0.2) "levelwide"
  419. }
  420.  
  421.     for (local.i=1;local.i<level.weatherRs+1;local.i++)
  422.     {
  423.         if (level.rainvolume < 0)
  424.             level.weatherR[local.i] stoploopsound
  425.         else
  426.         {
  427.             level.weatherR[local.i] loopsound rain_roof (level.rainvolume + 0.2) // "levelwide"
  428. //            println ("rainroof at " + ((level.rainvolume + 0.2) / 2.5))
  429.         }
  430.  
  431.     }
  432.  
  433.     for (local.i=1;local.i<level.weatherWs+1;local.i++)
  434.     {
  435.         if (level.rainvolume < 0)
  436.             level.weatherW[local.i] stoploopsound
  437.         else
  438.             level.weatherW[local.i] loopsound rain_window (level.rainvolume + 0.2) // "levelwide"
  439.     }
  440.  
  441.     /*
  442.     for (local.i=1;local.i<level.winds+1;local.i++)
  443.     {
  444.         if (level.rainvolume < 0)
  445.             level.wind[local.i] stoploopsound
  446.         else
  447.         if (level.rainvolume > 0.5)
  448.             level.wind[local.i] loopsound "sound/environment/wind_weak.wav" (level.rainvolume + 0.2) 192
  449.         else
  450.             level.wind[local.i] loopsound "sound/environment/wind_strong.wav" level.rainvolume 192
  451.     }
  452.     */
  453.  
  454.  
  455. end
  456.  
  457. treemovement:
  458.     local.num = (level.raindensity + 1.5) / 2.5
  459.     setcvar "r_static_shadermultiplier1" local.num
  460.     wait 1
  461.     goto treemovement
  462. end
  463.  
  464.  
  465. playersoundorg:
  466. self.origin = $player.origin
  467. // self glue $player
  468. end
  469.  
  470. rainin:
  471. self waittill trigger
  472. level.raindest = 1.0
  473. wait 0.1
  474. goto rainin
  475. end
  476.  
  477. rainout:
  478. self waittill trigger
  479. level.raindest = 0.0
  480. wait 0.1
  481. goto rainout
  482. end
  483.  
  484. replaysound:
  485.     wait 35.5
  486.  
  487.     $playersound stopsound 5
  488.  
  489.         local.rainvolume = level.rainvolume - 0.3
  490.         local.rainvolume = local.rainvolume - level.rain
  491.  
  492.     if (local.rainvolume > 0)
  493.         $playersound loopsound rain_ext (local.rainvolume + 0.2) "levelwide"
  494.     else
  495.         $playersound loopsound rain_ext 0
  496.     goto replaysound
  497. end
  498.  
  499. replaysound2:
  500.     wait 14
  501.  
  502.     $playersound2 stopsound 5
  503.  
  504.     
  505.     if (level.rainvolume > 0.4)
  506.         local.rainvolume = (0.4 - (level.rainvolume - 0.4))
  507.     else
  508.         local.rainvolume = level.rainvolume
  509.     
  510.     local.rainvolume = local.rainvolume - level.rain
  511.  
  512.     if (local.rainvolume < 0.0)
  513.         $playersound2 loopsound rain_puddle 0
  514.     else
  515.         $playersound2 loopsound rain_puddle (local.rainvolume + 0.2) "levelwide"
  516.     goto replaysound2
  517. end
  518.